/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package woaini.wind.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.HeaderParameter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SwaggerConfig implements WebMvcConfigurer {

    @Value("${spring.application.name:我的应用}")
    private String applicationName;

    @Bean
    public OpenAPI springShopOpenAPI() {
    return new OpenAPI()
        .components(
            new Components()
                .addParameters(
                    "token",
                    new HeaderParameter().description("请填写Token").schema(new StringSchema()))
                .addParameters(
                    "adminID",
                    new HeaderParameter().description("请填写用户ID").schema(new StringSchema())))
        .info(
            new Info()
                .title(applicationName)
                .description("Knife4j增强文档")
                .version("v2.0")
                .license(new License().name("Apache 2.0").url("http://springdoc.org")));
    }
}
